<?php

namespace app\common\controller;

class Token
{
    /**
     * token生成
     * @return mixed
     */
    public function generateToken()
    {
        $v = 1;
        $key = mt_rand();
        // 生成带有密钥的哈希值
        $hash = hash_hmac("sha1", $v . mt_rand() . time(), $key, true);
        $token = str_replace('=', '', strtr(base64_encode($hash), '+/', '-_'));
        return $token;
    }
    

}
